<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<%@include file="/views/global/ShopInclude.jsp"%>
<link href="static/css/page/index.css" rel="stylesheet" type="text/css" />
<link href="static/css/page/shops.css" rel="stylesheet" type="text/css">
<link href="static/css/page/category.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="static/javascript/jquery.min.js"></script>
<title>CATEGORY</title>
</head>
<body class="categorybody">
	<%@include file="/views/global/SearchBar.jsp"%>

	<!-- CATEGORY 内容开始 -->
	<div class="independentBrandContent font">
		<%@include file="/views/global/ShopLeftMenu.jsp" %>

		<div class="brandContentRight">
			<!-- brand结果排序选项 start -->
			<div style="overflow: hidden;zoom: 1;height: 41px;">
			<ul class="brandContentSort" style="margin-left: 0;">
				<c:choose>
					<c:when test="${'gmtModified' eq searchVo.orderBy }">
						<li class="${searchVo.order }">最新 NEW<span class="active" value="gmtModified"></span></li>
					</c:when><c:otherwise>
						<li class="desc">最新 NEW<span value="gmtModified"></span></li>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${'likeNum' eq searchVo.orderBy }">
						<li class="${searchVo.order }">最热 HOT<span class="active" value="likeNum"></span></li>
					</c:when><c:otherwise>
						<li class="desc">最热 HOT<span value="likeNum"></span></li>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${'soldOut' eq searchVo.orderBy }">
						<li class="${searchVo.order }">销量 SALES<span class="active" value="soldOut" style="margin-right: 5px;"></span></li>
					</c:when><c:otherwise>
						<li class="desc">销量 SALES<span value="soldOut" style="margin-right: 5px;"></span></li>
					</c:otherwise>
				</c:choose>
			</ul>
			<!-- brand结果排序选项 end -->
			<!-- category页码 -->
			<form id="submitForm" name="submitForm" action="${actionPath }" method="post">
				<input type="hidden" name="pageIndex" value="1" />
				<input type="hidden" name="keyword" value="${searchVo.keyword }"/>
				<input type="hidden" name="categoryIdPath" value="${searchVo.categoryIdPath }"/>
				<input type="hidden" name="countryId" value="${searchVo.countryId }"/>
				<input type="hidden" name="orderBy" value="${searchVo.orderBy }"/>
				<input type="hidden" name="order" value="${searchVo.order }"/>
			</form>
			<div class="pagination-simple categoryPagination">
				<pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }"
					formName="submitForm" gotoFunction="switchPage"
					className="pagination-prev"></pagination:pagenav>
			</div>
			</div>
			<!-- category页码 结束 -->
			<div class="categoryContentList">
				<ul>
					<c:forEach var="item" items="${entryList }">
						<li class="categoryItem">
							<a href="item/detail?id=${item.id }" target="_blank">
								<img class="categoryPortrait" src="${fileServerBasePath }image/resize/${fn:substring(item.mainUrl, 9, fn:length(item.mainUrl)) }?width=180&height=180" />
							</a>
							<div class="categoryName">${item.title }<br />${item.cnName }</div>
							<div class="categoryPrice"> RMB ${item.price } 
								<a href="javascript:void(0)" onclick="itemFavorite(this,'${item.id}')" class="categoryFavoriteBtn"></a>
							</div>
						</li>
					</c:forEach>
				</ul>
				<!-- 提示框 -->
				<div id="searchwarning" class="warningdialog">
				  <p>WARNING 提醒<a href="javascript:void(0)" onclick="$('#searchwarning').hide();"></a></p>
				  <div class="warningdialogcontent">
				      SORRY,NO FOUND.<br>暂无搜到您想要的结果。<br>
				      <input type="button" value="确定 YES" onclick="$('#searchwarning').hide();">
				  </div>
				</div>
				<!-- 提示框    结束-->
			</div>
			<!-- category页码 -->
			<div class="pagination-simple">
				<pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }"
					formName="submitForm" gotoFunction="switchPage"
					className="pagination-prev"></pagination:pagenav>
			</div>
			<!-- category页码 结束 -->
		</div>
	</div>
	<form id="requestItemFavoriteForm" action=""></form>
	<!-- CATEGORY 内容结束 -->

<%@include file="/views/global/scripts.jsp"%>
<script type="text/javascript" src="static/javascript/page/shops.js"></script>
<%@include file="/views/global/footer.jsp"%>
<script type="text/javascript">
$(document).ready(function(){
	<c:if test="${empty entryList }">$("#searchwarning").show();</c:if>
	<c:if test="${not empty searchVo.categoryIdPath }">
		$(".brandNavLeft").children().removeClass("brandTriCategoryactive");
		$(".brandNavLeft").find("li[idpath='${searchVo.categoryIdPath}']").addClass("brandTriCategoryactive");
	</c:if>
	$(".brandContentSort").find("SPAN").click(function(){
		var target = this;
		if($(target).hasClass("active")){
			var order = $(target).parent().attr("class");
			$("INPUT[name='order']", "#submitForm").val("desc"==order?"asc":"desc");
		} else {
			$("INPUT[name='orderBy']", "#submitForm").val($(target).attr("value"));
			$("INPUT[name='order']", "#submitForm").val("desc");
		}
		switchPage(1);
	});
});

function switchPage(pageNo) {
	$("INPUT[name='pageIndex']", "#submitForm").val(pageNo);
	document.forms["submitForm"].submit();
}
function itemFavorite(target, id) {
	$("#requestItemFavoriteForm").goAjax({
		url:"item/statistics/like",
		type: "POST",
		semantic:false,
		checkLogin: true,
		dataType: "json",
		data:{itemId: id},
		success:function(jsonData){
		if(false == jsonData.success){
			$.error(jsonData.message);
		} else {
			if(jsonData.message=="-1"){
				var left = parseInt($(target).offset().left)+10, top =  parseInt($(target).offset().top)-10, obj=$("target");
			     $(target).append('<div id="zhan"><b>-1<\/b></\div>');
			     $('#zhan').css({'position':'absolute','z-index':'1', 'color':'#C30','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
			          $(this).fadeIn('fast').remove();
			     });
			     $(target).css("background-image","url(static/images/page/independentBrand/brandFavorite.png)");
			}else if(jsonData.message=="1"){
				var left = parseInt($(target).offset().left)+10, top =  parseInt($(target).offset().top)-10, obj=$(".favoriteBtn");
			     $(target).append('<div id="zhan"><b>+1<\/b></\div>');
			     $('#zhan').css({'position':'absolute','z-index':'1', 'color':'#C30','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
			          $(this).fadeIn('fast').remove();
			     });
			     $(target).css("background-image","url(static/images/page/independentBrand/brandFavorite2.png)");
			}
			//$.message("OPERATION SUCCESSFUL! ", {time: 2});
			//$(target).removeClass("brandFavoriteBtn").addClass("brandFavoriteBtn2");
		 }
		}
	});
}
</script>
</body>
</html>
